package v3.chapter1.t13_1;
 
public class Run {

	public static void main(String[] args) {
		try {
			MyThread thread = new MyThread();
			thread.start();
			Thread.sleep(2000);
			thread.interrupt();

		} catch (InterruptedException e) {
			System.out.println("main catch");
			e.printStackTrace();
		}

		System.out.println("end!");

	}

}

class MyThread extends Thread {

	@Override
	public void run() {
		super.run();

		try {
			for (int i = 0; i < 500000; i++) {
				if (this.interrupted()) {
					System.out.println("已经是停止状态了！我要退出了！");
					throw new InterruptedException();
				}
				System.out.println("i=" + (i + 1));
			}
			System.out.println("我在for下面！");
		} catch (InterruptedException e) {
			System.out.println("进MyThread.java 类 run 方法中的 catch了！");
			e.printStackTrace();
		}

	}

}